/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	         </p>
 * <p>创建者   :	win7 
 * 
 * <p>描   述  :   MoneyDetailServiceImpl.java for com.pengtu.gsj.service.impl.jhgl    </p>
 * 
 * <p>最后修改 : $: 2017年6月29日-下午3:58:22 v 1.0.0	 win7   $ </p>
 * 
*/

package com.pengtu.gsj.service.impl.jhgl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.dao.jhgl.MoneyDetailDao;
import com.pengtu.gsj.entity.app.Attachment;
import com.pengtu.gsj.entity.jhgl.MoneyDetail;
import com.pengtu.gsj.service.jhgl.MoneyDetailService;
import com.pengtu.gsj.service.system.SystemManageService;

/**
 * 
 * MoneyDetailServiceImpl
 * 
 * 2017年6月29日 下午3:58:22
 * 
 * @version 1.0.0
 * 
 */
@Transactional
@Service
public class MoneyDetailServiceImpl implements MoneyDetailService{
	@Autowired
	private MoneyDetailDao moneyDetailDao;
	
	@Autowired
	private SystemManageService systemManageService;
	
	@Override
	public List<MoneyDetail> getMoneyDetails(QueryFilter queryFilter) {
		return moneyDetailDao.find(queryFilter);
	}

	@Override
	public Page<MoneyDetail> findMoneyDetail(Page<MoneyDetail> page, QueryFilter queryFilter) {
		return moneyDetailDao.findPage(page, queryFilter);
	}

	@Override
	public MoneyDetail getMoneyDetail(String id) {
		return moneyDetailDao.get(id);
	}

	@Override
	public void saveMoneyDetail(MoneyDetail moneyDetail) {
		moneyDetailDao.save(moneyDetail);
	}

	@Override
	public void delateMoneyDetail(MoneyDetail moneyDetail) {
		if(moneyDetail.getAttachments() != null){
			for(Attachment attachment : moneyDetail.getAttachments()){
				systemManageService.deleteAttachment(attachment);
			}
		}
		moneyDetailDao.delete(moneyDetail);
	}
}
